/*
 * Copyright Guoling.com All right reserved. This software is the confidential and proprietary information of
 * Guoling.com ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with Guoling.com.
 */
package com.yunji.framework_template.common.util;

import com.yunji.framework_template.common.constant.Constant;

/*
 * 类ErrorMessage.java的实现描述：TODO 类实现描述
 * @author ddp1j32 2015-6-8 上午11:17:43
 */
public class ErrorMessageUtil {

    /**
     * 组装错误信息
     * 
     * @param erroCode 错误代码
     * @param errorDesc 错误描述
     * @return 错误信息
     */
    public static String getErrorMessage(String erroCode, String errorDesc) {
        return getErrorMessage(erroCode, errorDesc, null);
    }

    /**
     * 组装错误信息
     * 
     * @param erroCode 错误代码
     * @param errorDesc 错误描述
     * @param errInfo 具体错误信息
     * @return 错误信息
     */
    public static String getErrorMessage(String erroCode, String errorDesc, String errInfo) {
        StringBuilder sb = new StringBuilder(erroCode).append(Constant.COLON).append(errorDesc);
        if (!StringUtil.isEmpty(errInfo)) {
            sb.append(Constant.LEFT_SQUARE_BRACKETS).append(errInfo).append(Constant.RIGHT_SQUARE_BRACKETS);
        }
        return sb.toString();
    }
}
